import api from './index'
import { axios } from '@/utils/request'
import {ACCESS_TOKEN} from "@/store/mutation-types"

/**
 * login func
 * parameter: {
 *     username: '',
 *     password: '',
 *     remember_me: true,
 *     captcha: '12345'
 * }
 * @param parameter
 * @returns {*}
 */

export function registerWxLogin(parameter) {
  return axios({
    url: '/online/user/registerWxLogin',
    method: 'post',
    data: parameter
  })
}

export function login(parameter) {
  return axios({
    url: '/online/user/getCodeLogin',
    method: 'post',
    data: parameter
  })
}

export function phoneLogin(parameter) {
  return axios({
    url: '/online/phoneLogin',
    method: 'post',
    data: parameter
  })
}

export function getSmsCaptcha(parameter) {
  return axios({
    url: api.SendSms,
    method: 'post',
    data: parameter
  })
}

export function getInfo() {
  return axios({
    url: '/online/user/info',
    method: 'get',
  })
}

export function logout(logoutToken) {
  let parameter = {};
  parameter[ACCESS_TOKEN] = logoutToken;
  return axios({
    url: '/online/request/getLogOut',
    method: 'post',
    data: parameter,
  })
}